package com.example.demofx.util;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class https {
    public static String Get(String _url){
        String result ="" ;
        BufferedReader inData = null;
        try{
            URL url = new URL(_url);
            URLConnection urlConnection=url.openConnection();
            urlConnection.setRequestProperty("accept","*/*");
            urlConnection.setRequestProperty("connection","keep-alive");
            urlConnection.setRequestProperty("user-agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36");
            urlConnection.connect();
            InputStreamReader inputStreamReader = new InputStreamReader(urlConnection.getInputStream());
            inData = new BufferedReader(inputStreamReader);
            String lineData="";
            while((lineData = inData.readLine()) != null){
                result += lineData;
            }
        }
        catch (Exception e){
            System.out.println("get操作异常"+ e.getMessage());


        }finally{
            try{
                if(inData != null){
                    inData.close();
                }
            }catch(Exception e){

                System.out.println("getIO异常"+ e.getMessage());
            }

        }
        return result;
    }

}
